//
//  GoodsRowsTableViewCell.m
//  JinYong_iOS_Store
//
//  Created by 王厚一 on 2017/10/20.
//  Copyright © 2017年 why. All rights reserved.
//

#import "GoodsRowsTableViewCell.h"

@interface GoodsRowsTableViewCell ()

@property (nonatomic,strong) UILabel *goodsName;//商品名称
@property (nonatomic,strong) UILabel *goodsCount;//商品数量
@property (nonatomic,strong) UILabel *goodsPrice;//商品价格

@end

@implementation GoodsRowsTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createView];
    }
    return self;
}

- (void)createView {
    self.goodsName = ({
        UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(ActualW(15), ActualH(4), ActualW(150), ActualH(14))];
        label.textColor = RGB(51, 51, 51);
        label.font = FontX(FONTSIZE(13));
        label;
    });
    [self.contentView addSubview:self.goodsName];
    
    self.goodsCount = ({
        UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(ActualW(250), ActualH(4), ActualW(150), ActualH(14))];
        label.textColor = RGB(64, 136, 247);
        label.textAlignment = NSTextAlignmentLeft;
        label.font = FontX(FONTSIZE(13));
        label;
    });
    [self.contentView addSubview:self.goodsCount];
    
    self.goodsPrice = ({
        UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(ActualW(280), ActualH(4), ActualW(65), ActualH(14))];
        label.textColor = RGB(51, 51, 51);
        label.textAlignment = NSTextAlignmentRight;
        label.font = FontX(FONTSIZE(13));
        label;
    });
    [self.contentView addSubview:self.goodsPrice];
}

- (void)reloadDataWithModel:(GoodsRowsModel *)model{
  
    if ([model.order_goods_num integerValue] > 1) {
        self.goodsCount.textColor = RGB(64, 136, 247);
    }else {
        self.goodsCount.textColor = RGB(51, 51, 51);
    }
    
    self.goodsName.text = model.goods_name;
    if (![model.order_goods_num isEqualToString:@""]) {
        self.goodsCount.text = [NSString stringWithFormat:@"x%@",model.order_goods_num];
    }else {
        self.goodsCount.text = @"";
    }
    self.goodsPrice.text = model.goods_price;
    
}

@end
